<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
$uniacid = $_W['uniacid'];
$uid = $_W['member']['uid'];
$openid = $_W['openid'];
load()->func('tpl');
load()->func('logging');  
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';

$sec = $this->module['config'];
$xcxid = intval(trim($sec['xcxid'])) ;

if($operation == 'savepost'){
    /*提交保存数据*/
    
    $mobile = trim($_GPC['mobile']);
    $broker = pdo_fetch("select * from ".tablename("kbwdl_broker")." where mobile='$mobile' and uniacid='$xcxid'");
    if(!empty($broker)){
         $data = array('gzhopenid'=> $openid);
         pdo_update( 'kbwdl_broker', $data, array('id'=> $broker['id']));
    }
    //message("绑定成功", $this->createMobileUrl('binduser'  ));
}
$isbind = 0;
$mobile = '';
$broker = pdo_fetch("select * from ".tablename("kbwdl_broker")." where gzhopenid='$openid' and uniacid='$xcxid'");
if(!empty($broker)) {
    $mobile = $broker['mobile'];
    $nickname = $broker['nickname'];
    $avatar = tomedia($broker['avatar']);
    $isbind = 1;
}
include $this->template("binduser");

?>
